don't open transactions for SHOW and SET statements - reduces some redundancy of...
authorDomas Mituzas <midom@users.mediawiki.org>
Sun, 13 Jan 2008 13:34:45 +0000 (13:34 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Sun, 13 Jan 2008 13:34:45 +0000 (13:34 +0000)
includes/Database.php

index f611f8e..0548b7c 100644 (file)
@@ -759,9 +759,13 @@ class Database {
 
                # If DBO_TRX is set, start a transaction
                if ( ( $this->mFlags & DBO_TRX ) && !$this->trxLevel() && 
-                       $sql != 'BEGIN' && $sql != 'COMMIT' && $sql != 'ROLLBACK' 
-               ) {
-                       $this->begin();
+                       $sql != 'BEGIN' && $sql != 'COMMIT' && $sql != 'ROLLBACK') {
+                       // avoid establishing transactions for SHOW and SET statements too -
+                       // that would delay transaction initializations to once connection 
+                       // is really used by application
+                       $sqlstart = substr($sql,0,10); // very much worth it, benchmark certified(tm)
+                       if (strpos($sqlstart,"SHOW ")!==0 and strpos($sqlstart,"SET ")!==0) 
+                               $this->begin(); 
                }
 
                if ( $this->debug() ) {